package com.lx.ngsl.exam.analysis.service;

import java.util.List;
import java.util.Map;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Service;

import com.lx.ngsl.util.DaoUtil;

@Service
public class AnalysisService {
	
	@PersistenceContext
	private EntityManager em;
	

	/*
	 * 查询统计数据
	 */
	public List<Map<String, Object>> getTjData(){
		
		String sql = "select q.id,q.TAG,IFNULL(q.count,IFNULL(sum(w.num),0)) as count,IFNULL(sum(w.num),0) as num,IFNULL(sum(w.wrong),0) as wrong " + 
				"from v_quest_tj q " + 
				"LEFT JOIN v_quest_wrong_tj w " + 
				"on q.id = w.tag " + 
				"GROUP BY q.id,q.tag,w.tag " + 
				"ORDER BY q.id asc";
		return DaoUtil.query(em, sql);
	}
}
